package com.bjsxt.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bjsxt.pojo.Users;
import com.bjsxt.service.UserLoginService;

import javassist.NotFoundException;
/**
 * 用户登陆
 * @author 程应康
 *
 */
@Controller
public class UserLoginController {
	@Autowired
	private UserLoginService userLoginService;
	
	@RequestMapping("userLogin")
	@ResponseBody
	public String userLogin(Users users,HttpSession session) {
		try {
			Users user = userLoginService.findUserByProperty(users);
			System.out.println(user.getUsername()+"\t"+users.getUserpwd());
			session.setAttribute("users", user);
			return "t";
		} catch (NotFoundException e) {
			e.printStackTrace();
			return "f";
		} 
	}
}
